<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模型训练管理 - AI 中心</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .nav-pills .nav-link.active {
            background-color: #0d6efd;
        }
        .model-card {
            transition: transform 0.2s;
        }
        .model-card:hover {
            transform: translateY(-5px);
        }
        .training-log {
            height: 300px;
            overflow-y: auto;
            background-color: #1e1e1e;
            color: #fff;
            font-family: monospace;
            padding: 1rem;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">模型训练管理</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="../index.html">返回 AI 中心</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <!-- 左侧导航 -->
            <div class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
                <div class="position-sticky pt-3">
                    <ul class="nav flex-column nav-pills">
                        <li class="nav-item">
                            <a class="nav-link active" href="#model-list" data-bs-toggle="pill">
                                <i class="bi bi-list-ul me-2"></i>模型列表
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#training-config" data-bs-toggle="pill">
                                <i class="bi bi-gear me-2"></i>训练配置
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#training-logs" data-bs-toggle="pill">
                                <i class="bi bi-journal-text me-2"></i>训练日志
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- 右侧内容 -->
            <div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
                <div class="tab-content">
                    <!-- 模型列表 -->
                    <div class="tab-pane fade show active" id="model-list">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">模型列表</h1>
                            <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newModelModal">
                                <i class="bi bi-plus-lg"></i> 新建模型
                            </button>
                        </div>

                        <div class="row">
                            <!-- LSTM模型 -->
                            <div class="col-md-6 col-lg-4 mb-4">
                                <div class="card model-card">
                                    <div class="card-body">
                                        <div class="d-flex justify-content-between align-items-center mb-3">
                                            <h5 class="card-title mb-0">LSTM预测模型</h5>
                                            <span class="badge bg-success">已部署</span>
                                        </div>
                                        <p class="card-text">用于时间序列预测的LSTM模型</p>
                                        <div class="mb-3">
                                            <small class="text-muted">最后更新：2024-03-10</small>
                                        </div>
                                        <div class="d-flex justify-content-between">
                                            <button class="btn btn-sm btn-outline-primary">查看详情</button>
                                            <button class="btn btn-sm btn-outline-danger">删除</button>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- XGBoost模型 -->
                            <div class="col-md-6 col-lg-4 mb-4">
                                <div class="card model-card">
                                    <div class="card-body">
                                        <div class="d-flex justify-content-between align-items-center mb-3">
                                            <h5 class="card-title mb-0">XGBoost分类模型</h5>
                                            <span class="badge bg-warning">训练中</span>
                                        </div>
                                        <p class="card-text">用于异常检测的XGBoost模型</p>
                                        <div class="mb-3">
                                            <small class="text-muted">开始时间：2024-03-10 15:30</small>
                                        </div>
                                        <div class="d-flex justify-content-between">
                                            <button class="btn btn-sm btn-outline-primary">查看进度</button>
                                            <button class="btn btn-sm btn-outline-danger">停止训练</button>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- 随机森林模型 -->
                            <div class="col-md-6 col-lg-4 mb-4">
                                <div class="card model-card">
                                    <div class="card-body">
                                        <div class="d-flex justify-content-between align-items-center mb-3">
                                            <h5 class="card-title mb-0">随机森林模型</h5>
                                            <span class="badge bg-secondary">未部署</span>
                                        </div>
                                        <p class="card-text">用于设备状态分类的随机森林模型</p>
                                        <div class="mb-3">
                                            <small class="text-muted">创建时间：2024-03-09</small>
                                        </div>
                                        <div class="d-flex justify-content-between">
                                            <button class="btn btn-sm btn-outline-primary">开始训练</button>
                                            <button class="btn btn-sm btn-outline-danger">删除</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 训练配置 -->
                    <div class="tab-pane fade" id="training-config">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">训练配置</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-save"></i> 保存配置
                            </button>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">基本配置</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="mb-3">
                                            <label class="form-label">模型类型</label>
                                            <select class="form-select">
                                                <option>LSTM</option>
                                                <option>XGBoost</option>
                                                <option>随机森林</option>
                                            </select>
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">训练数据比例</label>
                                            <input type="range" class="form-range" min="0" max="100" value="80">
                                            <div class="d-flex justify-content-between">
                                                <small>0%</small>
                                                <small>80%</small>
                                                <small>100%</small>
                                            </div>
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">验证数据比例</label>
                                            <input type="range" class="form-range" min="0" max="100" value="20">
                                            <div class="d-flex justify-content-between">
                                                <small>0%</small>
                                                <small>20%</small>
                                                <small>100%</small>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">高级配置</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="mb-3">
                                            <label class="form-label">学习率</label>
                                            <input type="number" class="form-control" value="0.001" step="0.001">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">批次大小</label>
                                            <input type="number" class="form-control" value="32">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">训练轮数</label>
                                            <input type="number" class="form-control" value="100">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">早停轮数</label>
                                            <input type="number" class="form-control" value="10">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 训练日志 -->
                    <div class="tab-pane fade" id="training-logs">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">训练日志</h1>
                            <div>
                                <button class="btn btn-outline-primary me-2">
                                    <i class="bi bi-download"></i> 下载日志
                                </button>
                                <button class="btn btn-outline-danger">
                                    <i class="bi bi-trash"></i> 清除日志
                                </button>
                            </div>
                        </div>

                        <div class="card">
                            <div class="card-body">
                                <div class="training-log">
                                    <div>[2024-03-10 15:30:00] 开始训练 LSTM 模型</div>
                                    <div>[2024-03-10 15:30:01] 加载训练数据...</div>
                                    <div>[2024-03-10 15:30:02] 数据预处理完成</div>
                                    <div>[2024-03-10 15:30:03] 初始化模型参数</div>
                                    <div>[2024-03-10 15:30:04] 开始第 1 轮训练</div>
                                    <div>[2024-03-10 15:30:05] 训练损失: 0.5234</div>
                                    <div>[2024-03-10 15:30:06] 验证损失: 0.4987</div>
                                    <div>[2024-03-10 15:30:07] 开始第 2 轮训练</div>
                                    <div>[2024-03-10 15:30:08] 训练损失: 0.4123</div>
                                    <div>[2024-03-10 15:30:09] 验证损失: 0.3876</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 新建模型模态框 -->
    <div class="modal fade" id="newModelModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">新建模型</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="mb-3">
                            <label class="form-label">模型名称</label>
                            <input type="text" class="form-control" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">模型类型</label>
                            <select class="form-select">
                                <option>LSTM</option>
                                <option>XGBoost</option>
                                <option>随机森林</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">模型描述</label>
                            <textarea class="form-control" rows="3"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary">创建</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 